Skip to content

Add mesa snapshot overlay #72

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 9 commits into
base: main
Choose a base branch
from
Open

Add mesa snapshot overlay #72

wants to merge 9 commits into from

Conversation

lumag
Copy link
Contributor

@lumag lumag commented Jun 12, 2025

In order to evaluate upstream Mesa on the RB1 board, package the snapshot of the Mesa development tree. This package will go away once Mesa 25.2 gets released and enters Debian experimental or unstable.

@lool
Copy link
Contributor

lool commented Jun 12, 2025

I gave this a cursory read to review the general approach, and it's as we discussed. I'm not super happy that we duplicate packaging in this repo and that we allow for calling random scripts, but that works in the short-term.

@basak-qcom Would you be able to do a full review? Or I can do one on Monday

Copy link

github-actions bot commented Jun 12, 2025

Test Results

 2 files  ±0   4 suites  ±0   6m 20s ⏱️ +23s
15 tests ±0  15 ✅ ±0  0 💤 ±0  0 ❌ ±0 
38 runs  ±0  38 ✅ ±0  0 💤 ±0  0 ❌ ±0 

Results for commit ba0c2a3. ± Comparison against base commit ca08110.

♻️ This comment has been updated with latest results.

Copy link

Test jobs for commit e5f2734

Copy link

Test jobs for commit 7ea28c1

Copy link
Contributor

@basak-qcom basak-qcom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[Comment only] Ideally we'd have a better mechanism to do all of this, such as packaging repositories in git that can derive from upstream and Debian packaging commits. But in the meantime to make progress we already have overlay-debs debdiffs as a compromise. Adding a generic script mechanism seems like a clean way of approaching this. Even though it's more creep towards the less ideal, I can't think of a better general approach.

[No change needed] We have a service dependency on gitlab.freedesktop.org being introduced here, whereas before we depended on Debian apt archives only I think. Again, given this is a stop-gap solution, I guess that's OK. Perhaps we should start noting these somewhere though.

[For discussion before landing] The debian/ directory and packaging inside gives me some concern. It's being copied from Debian experimental I think, and then being modified? Since our goal is to minimise any "delta" to upstream over time, ideally we'd store the diff rather than a copy. Notably this approach is the one we take with the overlay-debs debdiff mechanism, which is what this is building upon. I wouldn't do that for the entire upstream snapshot, but perhaps we can do that for the packaging, supplying a debdiff to apply over the source package once it has been constructed from the upstream git commit and the debian directory from Debian experimental? Otherwise, it took me some effort to fetch and generate a diff against Debian experimental to review, and then I'm finding it difficult to understand why you've changed some aspects of the packaging against Debian experimental. For someone else to understand that is key to allowing that difference to be eliminated in the future. What do you think about storing a diff against experimental instead, and then generating that dynamically as part of the script?

[Changes requested] Please could you link directly to the upstream PRs or commits that you are cherry-picking from the patch files themselves? For example there's dep3 which describes what metadata should go into a patch in debian/patches. In this case of squashing multiple commits together, I think that's fine in which case maybe just dump the headers at the top? I don't know of any tool that reads these; it's just really useful when rebasing in the future, so I'd like to make it a standard that the information is available. I think this should be in the source tree itself rather than just in commits.

lumag added 3 commits June 17, 2025 16:13
In order to build upstream mesa snapshot we need to manually prepare
source directory. Add support for using the external script instead of
just fetching the dsc from Debian.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
In order to evaluate upstream Mesa on the RB1 board, package the
snapshot of the Mesa development tree. This package will go away once
Mesa 25.2 gets released and enters Debian experimental or unstable.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Import patchset from Mesa MR 35316, implementing 24-bit texture formats
support.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
@lumag
Copy link
Contributor Author

lumag commented Jun 17, 2025

@lool @basak-qcom reworked the PR

Corresponding packages were uploaded to OBS

Copy link

Test jobs for commit 53e17b8

Copy link
Contributor

@lool lool left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey, thanks for implementing this, and sorry for the delay in reviewing on my side; I've left mostly minor comments but please could you:

  • change the Debian revision to 0qcom1
  • add some notes on how you created the debdiff, either in the commit message or in debian/changelog inside the debdiff
  • pass this new script through the shellcheck workflow (.github/workflows/static-checks.yml only runs against ci/*.sh).

Thanks!

@@ -59,8 +59,24 @@
)
print("✅ Checksum of original source package matched.")

# Unpack the source package
subprocess.run(['dpkg-source', '-x', dsc_file], cwd=temp_dir, check=True)
script = config.get('script')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess this could be named "source_download_script"

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe source_unpack_script? Since it replaces the dpkg-source -x call, not the .dsc file download.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No. It does more than just dpkg-source -x. As such, I'd prefer to keep it as is. I think it should be possible to build an overlay deb without original DSC at all.

script = os.path.abspath(os.path.join(config_dir, script))

env = os.environ.copy()
env['DSC_FILE'] = dsc_file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd prefer if we passed the whole yaml file to the script, but I know it's not fun to parse yaml from shell; that's actual actually why I wrote build-deb in python, but now we're extending it to call a shell script :)

I guess this is a temporary solution and we need to get rid of this debdiff juggling logic ASAP, but this will do for now.

tar xJf ${DEB_FILE}

cat >> debian/changelog.tmp << EOF
mesa (${version}-0) experimental; urgency=medium
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

would you mind changing the version to 0qcom1 so that all packages with qcom changes have a qcom version?

@basak-qcom
Copy link
Contributor

basak-qcom commented Jun 20, 2025

I like the overall mechanism now - thanks! It's quite clean given the compromise we're already making - still based on a Debian dsc from the Debian snapshot archive, and the script doing the quite minimal upstream snapshot extraction before the debdiff is applied afterwards as normal for the packaging changes.

Next I looked at the packaging changes themselves. Here's a summary of all the changes I see to packaging against the base Debian 25.1.0-1 package:

  • Revert to LLVM 19 (LLVM 20 is not in trixie so this makes sense)
  • Build against librust-rustc-hash-2-dev, not librust-rustc-hash-dev (although both are in trixie?)
  • Drop packages
    • libxatracker2
    • libxatracker-dev
    • libd3dadapter9-mesa
    • libd3dadapter9-mesa-dev
  • Update libegl-mesa0.symbols with three new symbols
  • mesa-opencl-icd.install: drop some files
  • debian/patches/35316.patch: new patch ("freedreno: Add sampling support for RGB/BGR 24-bit component texture formats")
  • debian/patches/etnaviv-add-support-for-texelfetch.patch: drop (but it doesn't reverse-apply to this snapshot cleanly)
  • debian/patches/path_max.diff: tweak
  • debian/rules: various tweaks
  • debian/control regenerated from debian/control.in

With my Ubuntu background, I'm used to maintaining a delta against an upstream distribution, including upstream snapshots. In that context, there are usually a couple of concerns driven by the desire to converge back with upstream in the future:

  1. When it comes time to drop the delta, will this cause an unwanted change in user behaviour?
  2. When rebasing our delta onto a newer upstream version (because we can't or don't want to drop the delta yet), is each part of the delta appropriate to keep, does it need adjusting, or can we drop it without causing an unwanted change in user behaviour?

For this reason my default expectation is that the delta should be minimal and the reason for each part of the delta existing should be obvious or explained. In Ubuntu we have largely moved to using git to maintain the delta directly, so each part is a commit with an explanation. Here, with everything being squashed into the single debdiff, we don't have that ability yet, unfortunately. Nevertheless I can still apply my usual expectations, consider the debdiff and try to understand why each part is there.

How does my default expectation from Ubuntu map to this project? I'm not sure yet! With our "upstream first" philosophy, I think we are agreed that the delta needs to be kept at a minimum. I think the depth we need to spend on the details of the delta itself depends on what user stories we need to support with this package, together with our expectations on how long we will need to maintain this delta for. Is it possible that a mesa snapshot delta isn't short-lived because of another requirement that comes along in the future before the current requirement is upstreamed, for example?

Before we used git in Ubuntu, our convention was to explain the delta in debian/changelog including upon every rebase, and we still do that today. Since we can't use git, perhaps we could do the same here? For example:

mesa (25.2~2640-g8d13fc447e3-0qcom1) trixie; urgency=medium

  [ Dmitry Baryshkov ]
  * New upstream snapshot to evaluate upstream Mesa on the RB1 board. 
  * Backport to trixie:
    - Revert to building with LLVM 19 since 20 is not in trixie.
    - Drop packages: libxatracker2, libxatracker-dev,
      libd3dadapter9-mesa, libd3dadapter9-mesa-dev.
    - Build against librust-rustc-hash-2-dev, not librust-rustc-hash-dev
      [both are in trixie?].
    - Update libegl-mesa0.symbols.
    - d/mesa-opencl-icd.install: drop some files [does it fail to build without this?].
    - d/p/35316.patch: freedreno: Add sampling support for RGB/BGR
      24-bit component texture formats.
    - d/p/etnaviv-add-support-for-texelfetch.patch: drop [although it doesn't reverse apply exactly?]
    - debian/patches/path_max.diff: [tweak].
    - debian/rules: [tweak; multiple hunks here and the reasons for most aren't clear to me].
    - debian/control regenerated from debian/control.in.

 -- Robie Basak <robibasa@qti.qualcomm.com>  Fri, 20 Jun 2025 13:06:04 +0100

I've tweaked the version string to include qcom1 as Loic requested, and also tried to select something that should work for future updates smoothly.

Proposed next steps:

  1. I'm open to taking a different approach, or in less detail, if that seems appropriate.
  2. Otherwise, please could I have some help in explaining why we're making these changes to packaging by adjusting my changelog example above, replacing my lack of understanding annotated in the square brackets?

With help as above, I'd be happy to take over driving this to getting it landed if you like.

@lumag
Copy link
Contributor Author

lumag commented Jun 20, 2025

@basak-qcom too many words for a package that is going to be obsoleted in July or August. Could you please make your comments easier to comprehend?

lumag added 2 commits June 23, 2025 13:26
Update commit ID to a recent one, which, among other changes, pulls in
FP16 fixes in the freedreno driver.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Opt-in and use the gallium-rusticl-enable-drivers in order to enable
RustiCL drivers which can be enabled by default: asahi, freedreno and
radeonsi. The rest of the drivers still need an explicit RUSTICL_ENABLE
environment variable.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Copy link

Test jobs for commit ca86dfe

Specify debian revision as -0qcom1 instead of just -0 in order to point
out that it is a Qualcomm-specific build.

Signed-off-by: Dmitry Baryshkov <dmitry.baryshkov@oss.qualcomm.com>
Copy link

Test jobs for commit ba0c2a3

This fixes shellcheck "SC2086 (info): Double quote to prevent globbing
and word splitting."

Signed-off-by: Robie Basak <robibasa@qti.qualcomm.com>
@basak-qcom
Copy link
Contributor

@lumag I pushed 76162c8 directly to your branch to fix some shellcheck warnings. I'm confident that's unobjectionable. I trust that's appropriate process/etiquette here?

Three more changes to come: one remaining shellcheck issue, I'll add a README, and I'll rebase onto main in order to pick up the shellcheck CI changes. Please let me know if I should do this differently.

DSC_FILE is guaranteed to be defined as part of the call API from
build-deb.py here.

Signed-off-by: Robie Basak <robibasa@qti.qualcomm.com>
Signed-off-by: Robie Basak <robibasa@qti.qualcomm.com>
# be assigned. Did you mean DEB_FILE?
#
# DSC_FILE is guaranteed to be defined as part of the call API from build-deb.py
# shellcheck disable=SC2153
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

NAK, don't add extra noise.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just removing it will cause it to fail CI. Please clarify how you want me to fix it instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Then please fix the CI. Adding 5 lines of comments, including the tools output, just to make it ignore a variable name in the script is definitely an overkill.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we can probably do this on one line, something like:

# shellcheck disable=SC2153 # DSC_FILE is guaranteed to be defined by build-deb.py

or we could set DSC_FILE if unset at the top of the file, with a comment saying it should be set by build-dep.py

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my general comment on lint tools. I think this is fine as-is. I don't think it'd be productive to spend time iterating to find something that the linter will accept. It's wrong, so we can say it's wrong and move on. For the sake of a comment, I really think this is fine.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry, I hadn't seen lool's comment. If your suggestion is acceptable then sure - it's not worth the discussion.

can be enabled by default: asahi, freedreno and radeonsi.
+ Disable gallium-xa and gallium-opencl=icd.
+ No longer need to remove mme_{fermi,tu104}_sim_hw_test
- debian/control regenerated from debian/control.in.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just add this to the script so that it goes to the actual changelog.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree that would be better, but you are generating the changelog - parameterised - from your script. I didn't put this directly in there since it'll be wrong as soon as the parameters change. I can either keep it in the README.md as-is, or remove the changelog generation from the script and put a changelog entry via the debdiff instead. Which do you prefer?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Exactly because of that. If you want a detailed changelog entry, please generate it from the script. This way apt-listchanges will show it to users, making sure that they see any actual changes to the snapshot packaging.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be happy to generate it automatically from a script, but that would mean that we need separate commits with the same level of detail, and we can't do that right now because we're using flat debdiffs. This is the compromise we're making. If we want to land this in a practical timescale, I can keep the README.md, or remove the changelog generation and move the entire changelog statically into the debdiff. Which do you want?


rm -rf mesa
git clone --depth 1 https://gitlab.freedesktop.org/mesa/mesa

cd mesa
git fetch --depth 1 origin ${COMMIT##origin/}
git fetch --depth 1 origin "${COMMIT##origin/}"
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't need to quote all the variables. Only the variables that might have whitespaces or might be empty need to be quoted.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yup, shellcheck doesn't know that, so it asks to quote everything by default, but we can add an override to tell it to ignore this particular line; I think it's cheaper to add the double quotes personally, even if it's a bit more verbose

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my general comment on lint tools and CI. The compromise is that even though it's not necessary, it's not wrong, so this is fine as-is. That way we can have a linter and CI, which is better for our culture overall.

Copy link
Contributor

@basak-qcom basak-qcom left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we need to talk about CI and lint tools.

The culture I think we need to be heading towards is:

  1. Use linting in CI to give immediate contributor feedback and achieve a baseline of quality, both for our repositories and to set an example across the company.
  2. Lint tools are indeed dumb. They will make us do things that aren't necessary. That's the cost of achieving the previous point, but the benefit is worth the cost.
  3. When the lint tool is wrong, a simple override should be enough, using whatever mechanism the lint tooling provides. Best practice is to explain how the lint tool is wrong in a comment, to avoid suppressing the lint tooling when not appropriate ensuring that this can be reviewed effectively.
  4. If the linter is wrong, just override it and move on. I don't think it's worth the effort of trying to figure out how to work around the linter so that it won't alert.
  5. Fixing the linter is out of scope. Perfect is the enemy of the good. We have better uses for our time. Just using the linter gives us enough bang for the buck.
  6. This does mean apparently unnecessary noise, but the general best practice I'm used to is that it's worth the cost.

I'm surprised to see this being nitpicked here, and indeed this isn't something that's worth debating in a PR. The above should just be in a documented best practice document so that we do not endlessly debate this in PRs.

can be enabled by default: asahi, freedreno and radeonsi.
+ Disable gallium-xa and gallium-opencl=icd.
+ No longer need to remove mme_{fermi,tu104}_sim_hw_test
- debian/control regenerated from debian/control.in.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd be happy to generate it automatically from a script, but that would mean that we need separate commits with the same level of detail, and we can't do that right now because we're using flat debdiffs. This is the compromise we're making. If we want to land this in a practical timescale, I can keep the README.md, or remove the changelog generation and move the entire changelog statically into the debdiff. Which do you want?

# be assigned. Did you mean DEB_FILE?
#
# DSC_FILE is guaranteed to be defined as part of the call API from build-deb.py
# shellcheck disable=SC2153
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my general comment on lint tools. I think this is fine as-is. I don't think it'd be productive to spend time iterating to find something that the linter will accept. It's wrong, so we can say it's wrong and move on. For the sake of a comment, I really think this is fine.


rm -rf mesa
git clone --depth 1 https://gitlab.freedesktop.org/mesa/mesa

cd mesa
git fetch --depth 1 origin ${COMMIT##origin/}
git fetch --depth 1 origin "${COMMIT##origin/}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See my general comment on lint tools and CI. The compromise is that even though it's not necessary, it's not wrong, so this is fine as-is. That way we can have a linter and CI, which is better for our culture overall.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants